//
//  UIViewExtension.swift
//  Jock
//
//  Created by HD on 15/3/18.
//  Copyright (c) 2015年 Haidy. All rights reserved.
//

import UIKit

extension UIView {
    
    func getTop() -> CGFloat {
        return frame.origin.y
    }
    
    func getLeft() -> CGFloat {
        return frame.origin.x
    }
    
    func getRight() -> CGFloat {
        return getLeft() + frame.size.width
    }
    
    func getBottom() -> CGFloat {
        return getTop() + frame.size.height
    }
    
    func setX(x: CGFloat) {
        var rect: CGRect = self.frame
        rect.origin.x = x
        self.frame = rect
    }
    
    func setY(y: CGFloat) {
        var rect: CGRect = self.frame
        rect.origin.y = y
        self.frame = rect
    }
    
    func setHeight(height: CGFloat) {
        var rect: CGRect = self.frame
        rect.size.height = height
        self.frame = rect
        var bounds: CGRect = self.bounds
        bounds.size.height = height
        self.bounds = bounds
    }
    
    func setWidth(width: CGFloat) {
        var rect: CGRect = self.frame
        rect.size.width = width
        self.frame = rect
    }
}
